/**
 * @description 读取文件类型
*/

import fs from 'fs'
import { fileTypeFromFile, fileTypeFromBuffer, fileTypeFromStream } from 'file-type'

const getMime = async function (path) {
  let res = await fileTypeFromFile(path) || 'application/octet-stream'
  return res
  // const buffer = fs.readFileSync(path)
  // console.log(await fileTypeFromBuffer(buffer))
  // const stream = fs.createReadStream(path)
  // console.log(await fileTypeFromStream(stream));
}

// example
// getMime('../app.js')